package com.yidaba.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.yidaba.Commonality;

public class DbUtil {
	private static Log log = LogFactory.getLog(DbUtil.class);
	
	public static Connection getConnection(){
		Connection conn = null;
		try {
//				Class.forName("com.mysql.jdbc.Driver").newInstance();
			DbUtils.loadDriver("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(Commonality.jdbc,
					Commonality.user, Commonality.dbpassword);
			/*if("forum".equals(db)){
				conn = DriverManager.getConnection(Commonality.jdbc,
						Commonality.user, Commonality.dbpassword);
			}else if("yidabav1".equals(db)){
				conn = DriverManager.getConnection(Commonality.jdbc,
						Commonality.user, Commonality.dbpassword);
			}*/
		} catch (SQLException e) {
			e.printStackTrace();
			log.error(e);
		} 
		return conn;
	}
}
